package com.lsh.service.impl;

import com.lsh.dao.UserDao;
import com.lsh.pojo.User;
import com.lsh.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserDao userDao;
    @Override
    public User login(User user) {
        User userLogin = userDao.login(user);
        if(userLogin != null){
            if (userLogin.getPassword().equals(user.getPassword())){
                //密码正确
                return userLogin;
            } else {
                //密码错误
                throw new RuntimeException("密码错误");
            }
        } else {
            //用户名不存在
            throw new RuntimeException("用户名不存在");
        }
    }
}
